#include <stdio.h>
int main()
{
    int row = 0;
    int a = 0;
    for(a = 0;a < row;a++)
    {
        int numa = 0;
        int numb = 0;
        int numc = 0;
        scanf("%d %d %d",&numa,&numb,&numc);
    }
    int b = 0;
    int m = 0;
    scanf("%d",&m);
    for(b = 0;b < m;b++)
    {
        int q = 0;
        scanf("%d ",&q);
        if(q == numc)
        {
            printf("%d %d",numa,numb);
        }
    }
    return 0;
}
